//用户信息
var userInfo = {
	head_img: "https://front.mybmall.com/image/cbd.jpg",
	time: "30周2天",
}
// 最近7天
//var wData = {
//	y_name: "公斤(kg)",
//	x_name: "最近7天", //最近30天，孕期
//	y_min: 0,
//	y_max: 120,
//	label_show: true, //数值标签
//	w_data: [40, 45, 48, 50, 56, 60, 65], //体重值
//	x_data: ['1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7'], //x轴	
//	min_data: [60, 65, 70, 75, 80, 85, 90], //下线数据，
//	max_data: [30, 32, 35, 38, 40, 45, 50], //上线数据
//	label_name: "体重", //体脂/估重
//	legend: {
//		max: "最高",
//		name: "体重",
//		min: "最低",
//	},
//	interval: 0, //x_轴间隔
//};

var wData = {
	y_name: "公斤(kg)",
	x_name: "最近7天", //最近30天，孕期
	y_min: 0,
	y_max: 120,
	label_show: true, //数值标签
	w_data: [40, 45, 48, 50, 56, 60, 65], //体重值
	x_data: ['1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7'], //x轴
	min_data: [30, 32, 35, 38, 40, 45, 50], //下线数据，
	max_data: [60, 65, 70, 75, 80, 85, 90], //上线数据
	label_name: "体重", //体脂/估重
	legend: {
		min: "最低",
		weight: "体重",
		max: "最高",
	},
	interval: 0, //x_轴间隔
};

//最近30天
var mData = {
	y_name: "公斤(kg)",
	x_name: "最近30天", //最近30天，孕期
	y_min: 0,
	y_max: 120,
	label_show: false, //数值标签
	w_data: [40, 45, 48, 50, 56, 60, 65, 65, 68, 70,
		40, 45, 48, 50, 56, 60, 65, 65, 68, 70,
		40, 45, 48, 50, 56, 60, 65, 65, 68, 70
	], //体重值
	x_data: ['1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10',
		'1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20',
		'1.21', '1.22', '1.23', '1.24', '1.25', '1.26', '1.27', '1.28', '1.29', '1.30'
	], //x轴
	min_data: [30, 32, 35, 38, 40, 45, 50, 60, 50, 55,
		30, 32, 35, 38, 40, 45, 50, 60, 50, 55,
		30, 32, 35, 38, 40, 45, 50, 60, 50, 55
	], //下线数据，
	max_data: [60, 65, 70, 75, 80, 85, 90, 90, 95, 100,
		60, 65, 70, 75, 80, 85, 90, 90, 95, 100,
		60, 65, 70, 75, 80, 85, 90, 90, 95, 100
	], //上线数据
	label_name: "体重", //体脂/估重
	legend: {
		min: "最低",
		weight: "体重",
		max: "最高",
	},
	interval: 3, //x_轴间隔
};

//全孕期  已周为单位  每周为一个点 ，全部 输出
var yData = {
	y_name: "公斤(kg)",
	x_name: "孕期(40周)", //最近30天，孕期
	y_min: 0,
	y_max: 120,
	label_show: false, //数值标签
	w_data: [40, 45, 48, 50, 56, 60, 65, 65, 68, 70,
		40, 45, 48, 50, 56, 60, 65, 65, 68, 70,
		40, 45, 48, 50, 56, 60, 65, 65, 68, 70,
		40, 45, 48, 50, 56, 60, 65, 65, 68, 70,
	], //体重值
	x_data: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
		"11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
		"21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
		"31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
	], //x轴
	min_data: [30, 32, 35, 38, 40, 45, 50, 60, 50, 55,
		30, 32, 35, 38, 40, 45, 50, 60, 50, 55,
		30, 32, 35, 38, 40, 45, 50, 60, 50, 55,
		30, 32, 35, 38, 40, 45, 50, 60, 50, 55
	], //下线数据，
	max_data: [60, 65, 70, 75, 80, 85, 90, 90, 95, 100,
		60, 65, 70, 75, 80, 85, 90, 90, 95, 100,
		60, 65, 70, 75, 80, 85, 90, 90, 95, 100,
		60, 65, 70, 75, 80, 85, 90, 90, 95, 100
	], //上线数据
	label_name: "体重", //体脂/估重
	legend: {
		min: "最低",
		weight: "体重",
		max: "最高",
	},
	interval: 38, //x_轴间隔
};

var week_date = ["第一周", "第一周", "第一周", "第一周", "第一周", "第一周"];
var month_date = [];

$(function() {
	var w_history = document.getElementById("w_history");
	var m_history = document.getElementById("m_history");
	var w_weight = document.getElementById('w_weight'); //体重
	var m_weight = document.getElementById('m_weight'); //体重
	var y_weight = document.getElementById('y_weight'); //体重

	var w_zhifang = document.getElementById('w_zhifang');
	//	var m_zhifang = document.getElementById('m_zhifang');
	//	var y_zhifang = document.getElementById('y_zhifang');

	var b_zhifang = document.getElementById("b_zhifang");

	$("#headImg").attr('src', userInfo.head_img);
	$("#headName").html(userInfo.time);
	console.log(echart(w_weight, wData));
	//切换 tabbar
	mui("#segmentedControl").on('tap', "a", function() {
		$(".mian").width($(".mui-table-view-cell").width());
		console.log(echart(w_zhifang, wData));
		console.log(echart(b_zhifang, wData));
	})
	setTimeout(function() {
		console.log(echart(m_weight, mData));
	}, 2000);

	setTimeout(function() {
		console.log(echart(y_weight, yData));
	}, 3000);

	//	//最近7天
	w_history.addEventListener("tap", function() {
		var div1 = '<li class="mui-table-view-cell cell_li" onclick="cheakItem(this)" id="',
			div2 = '"><a href="#">',
			div3 = '</a></li>';
		var div4 = '<li class="mui-table-view-cell cell_li"><a href="#">无数据</a></li>'
		$("#data_list").empty(); //清空被选元素的子元素
		if(week_date.length == 0) {
			$("#data_list").append(div4);
		} else {
			$.each(week_date, function(i, t) {
				$("#data_list").append(div1 + i + div2 + t + div3);
			})
		}
	});

	//	//最近30天
	m_history.addEventListener("tap", function() {
		var div1 = '<li class="mui-table-view-cell cell_li" onclick="cheakItem(this)" id="',
			div2 = '"><a href="#">',
			div3 = '</a></li>';
		var div4 = '<li class="mui-table-view-cell cell_li"><a href="#">无数据</a></li>'
		$("#data_list").empty(); //清空被选元素的子元素
		if(month_date.length == 0) {
			$("#data_list").append(div4);
		} else {
			$.each(month_date, function(i, t) {
				$("#data_list").append(div1 + i + div2 + t + div3);
			})
		}
	});
	mui('.mui-scroll-wrapper').scroll();
})

function cheakItem(e) {
	var es = $(e)
	var id = Number(es.attr("id")) + 1;
	//alert(id);
}